/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.test;

import com.comac.ins.common.json.utils.JsonUtils;
import com.comac.ins.common.redis.utils.RedisUtils;
import com.comac.ins.isfd.constant.RedisConstants;
import com.comac.ins.isfd.domain.vo.IsfdModelManagementStructureDefinitionTreeVo;
import com.comac.ins.isfd.service.IIsfdModelManagementStructureDefinitionTreeService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.Duration;

@SpringBootTest
public class RedisTest {
    @Autowired
    private IIsfdModelManagementStructureDefinitionTreeService iIsfdModelManagementStructureDefinitionTreeService;

    @Test
    public void test1() {
        String modelNumber = "C919";
        String batchNumber = "batch1";
        String sectionNumber = "";

        IsfdModelManagementStructureDefinitionTreeVo vo = iIsfdModelManagementStructureDefinitionTreeService.queryOneByQueryIndex(modelNumber, batchNumber, sectionNumber);
        String key = RedisConstants.ISFD_MODEL_MANAGEMENT_STRUCTURE_DEFINITION_TREE_QUERY_INDEX + vo.getQueryIndex();
        RedisUtils.setCacheObject(key, vo, Duration.ofDays(RedisConstants.QUERY_INDEX_EXPIRATION_DAY));
        IsfdModelManagementStructureDefinitionTreeVo treeVo = RedisUtils.getCacheObject(key);
        System.out.println(JsonUtils.toJsonString(treeVo));
    }
}
